home *** CD-ROM | disk | FTP | other *** search
/ ToolBook 3.0 / ToolBook v3.0.iso / tb30 / samples / mapi.tbk (.txt) < prev    next >
Encoding:
Asymetrix ToolBook File  |  1994-05-19  |  86.8 KB  |  1,653 lines

  1. Counting Messages
  2. Checking For Unread Mail
  3. Using MAPI
  4. Using MAPI+
  5. Microsoft's Messaging Application Programming Interface (MAPI) is a set of high level DLL functions that are the foundation of electronic mail in Windows. Applications use these functions to create, manipulate, transfer, and store messages.
  6. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach you MAPI. It is assumed that you are familiar with and have documentation for MAPI.
  7. The handlers which directly access the MAPI functions are all found in the script of this book.s which applications used to create, manipulate, transfer, and store messages. Most of these functions are exported from MAPI.DLL and form the basis for electronic mail in Windows.
  8. The scripts and examples in this book demonstrate how to access MAPI from ToolBook, but are not intended to teach MAPI to the user. In fact. it is assumed that user is familiar with and has documentation for MAPI.
  9. The handlers which directly access the MAPI functions are all found in the book script.
  10. Sending Messages
  11. Sending Messages
  12. Sending Messages5
  13. The example below illustrates how to send a message without using the MAPI dialog box. Fill in the fields below and click the button when you are ready to send the message..the message.
  14. Send Message
  15. }str_sent
  16. getAddress
  17. sendMessage
  18. s_MAPIError
  19. str_notSent
  20. buttonClick
  21. buttonClick
  22. 4s_MAPIError
  23. there 
  24. no recipient supplied
  25.         -- call up 
  26. 6 Address Book
  27. getAddress()
  28.         -- 
  29. we don't 
  30. address we won't 
  31. a message
  32.         -- fill 
  33.  appropriate 
  34. sendMessage(
  35. "sub",
  36. "body")
  37.     -- confirm whether 
  38.  was sent
  39. str_notSent()&&
  40. str_sent()
  41. &Send Message
  42. Bob N.
  43. We're almost there now.
  44. Don't blow it!
  45. Subject:
  46. Text:
  47. Submit Reports
  48. Receive Reports
  49. Receive Reports
  50. View New
  51. uupdateMessages
  52. buttonClick
  53. buttonClick
  54.     -- scan incoming mail 
  55. problem reports 
  56. setup the 
  57.     -- (
  58. message 
  59. handled 
  60. updateMessages 
  61. &View New
  62. delete
  63. [4deleteMessage
  64. uupdateMessages
  65. str_OK
  66. s_MsgHandles
  67. s_MsgNum
  68. s_MAPIError
  69. Rstr_notDelete
  70. buttonClick
  71. buttonClick
  72. 4s_MsgNum,s_MsgHandles,s_MAPIError
  73.     -- delete the current message
  74. deleteMessage(
  75. <> str_OK()
  76. str_notDelete()&&
  77.     -- refresh 
  78. [ list 
  79.     -- (
  80. handled 
  81. updateMessages 
  82. D&elete
  83. Previous
  84. 8parseMsgText
  85. s_MsgNum
  86. buttonClick
  87. buttonClick
  88. 4s_MsgNum
  89. mail message
  90. disable 
  91. G = 1
  92.         enabled 
  93. B"Next" = 
  94.     -- fill 
  95. ~fields 
  96.     -- (
  97. handled 
  98. parseMsgText
  99. &Previous
  100. Previous
  101. 8parseMsgText
  102. s_MsgCount
  103. s_MsgNum
  104. buttonClick
  105. buttonClick
  106. 4s_MsgNum,s_MsgCount
  107. tmessage
  108. , disable 
  109.         enabled 
  110. B"Previous" = 
  111.     -- fill 
  112. fields 
  113.     -- (
  114. handled 
  115. parseMsgText
  116. &Next
  117. Submit Reports
  118. Submit Reports
  119. buttonClick
  120. buttonClick
  121. "Submit Reports"
  122. &Submit Reports
  123. examples
  124. buttonClick
  125. buttonClick
  126. the example 
  127. Fclose 
  128. isOpen 
  129. "examples"
  130. &Done
  131. toLabel
  132. From:ss:
  133. problem
  134. Department
  135. address
  136. msgnum
  137. No messagesf 10
  138. toLabel
  139. Department:
  140. office
  141. phone
  142. toLabel
  143. Problem Area:
  144. toLabel
  145. Phone::::::::
  146. toLabel
  147. Office: Area:
  148. toLabel
  149. Description of problem:
  150. description
  151. toLabel
  152. Sent:ss:
  153. timestamp
  154. Example: Problem Reports
  155. Verifying Names
  156. -- a notify handler was used 
  157. the address 
  158. you enter 
  159. Verifying Names
  160. Verifying Names
  161. Click Check Names to get the full names of those displayed in the upper field and place them in the lower field.
  162. If a name is ambiguous, MAPI displays a dialog box that allows the user to choose the correct name.opriate... field. 
  163. If a name is ambiguous, MAPI will display a dialog allowing the user to choose which name is appropriate.
  164. Check Names
  165. 1,    #>
  166. checkNames
  167. partial
  168. s_MAPIError
  169. str_notResolved
  170. buttonClick
  171. buttonClick
  172. 4s_MAPIError
  173. a list 
  174. verified names 
  175. checkNames(
  176. "partial")
  177. error condition
  178. "full" = 
  179.         -- 
  180. some 
  181. hcould 
  182. xbe resolved:
  183.         -- the 
  184. value 
  185.         --    
  186. those that 
  187.         -- 
  188.         --    
  189. ,were 
  190. str_notResolved()&
  191. &Check Names
  192. partial
  193. Tom,Dick,Harry
  194. enterPage
  195. notifybefore 
  196. = "Tom,Dick,Harry"
  197. Tom,Dick,Harryelda
  198. enterPage
  199. notifybefore 
  200. enterPage
  201. examples
  202. Linking to MAPI.DLL
  203. Sending Messages
  204. Checking For Unread Mail
  205. -- notify handlers were used 
  206. [the fields 
  207. -- you enter 
  208. Checking For Unread Mail
  209. Checking For Unread Mail
  210. The script of this button steps through the messages in your incoming mail folder, looking for unread messages. The sender and subject of each unread message are placed in the fields below.. fields.
  211. Check for Unread Mail
  212. eck for Unread Mail
  213. Messages
  214. text area
  215. textScrolled
  216. buttonUp
  217. the fields together
  218. -- There are three 
  219. order 
  220. these 
  221. -- smoothly, 
  222. filled 
  223. fdummy 
  224. which has 
  225. -- same 
  226. other 
  227. . Only 
  228. b. When 
  229. scrolled, 
  230. 2two 
  231. -- If there were only 
  232. bar would 
  233. textScrolled 
  234. oselectedtextlines = 
  235. scrollbar
  236. enterPage
  237. notifybefore 
  238. Subject
  239. enterPage
  240. notifybefore 
  241. enterPage
  242. notifybefore 
  243. From:
  244. Subject:
  245. enterPage
  246. &Check for Unread Mail
  247. functions
  248. linkdll "mapi.dll"
  249.    DWORD MAPILogoff (DWORD, DWORD, DWORD, DWORD)
  250.    DWORD MAPILogon (DWORD, STRING, STRING, DWORD, DWORD, POINTER)
  251.    DWORD MAPIFindNext (DWORD, DWORD, DWORD, POINTER, DWORD, DWORD, \
  252.                                         POINTER)
  253.    DWORD MAPIFreeBuffer (POINTER)
  254.    DWORD MAPISendMail (DWORD, DWORD, POINTER, DWORD, DWORD)
  255.    DWORD MAPIReadMail (DWORD, DWORD, STRING, DWORD, DWORD, POINTER)
  256.    DWORD MAPIResolveName (DWORD, DWORD, STRING, DWORD, DWORD,  \
  257.                                               POINTER)        
  258.    DWORD MAPISendDocuments (DWORD, STRING, STRING, STRING, DWORD)    
  259.    DWORD MAPIAddress (DWORD, DWORD, STRING, DWORD, STRING, DWORD, \
  260.                                       DWORD, DWORD, DWORD, POINTER, POINTER)
  261.    DWORD MAPIDeleteMail (DWORD,DWORD,STRING,DWORD,DWORD)
  262. end linkDLL,STRING,DWORD,DWORD)
  263. end linkDLL
  264. buttonClick
  265. buttonClick
  266. isOpen 
  267. "link"
  268.         close 
  269. functions
  270. buttonClick
  271. Bcopies 
  272. clipboard
  273. buttonClick
  274.     -- place 
  275. "functions"
  276.     -- take 
  277. B"ok"
  278. &Copy to Clipboard
  279. &File
  280. &Open...    Ctrl+O
  281. &Save    Ctrl+S
  282. Save &As...
  283. saveas
  284. Print Set&up...
  285. printsetup
  286. &Print Pages...    Ctrl+P
  287. printpages
  288. &Run...
  289. E&xit    Alt+F4
  290. &Edit
  291. &Undo    Ctrl+Z
  292. Cu&t    Ctrl+X
  293. &Copy    Ctrl+C
  294. &Paste    Ctrl+V
  295. paste
  296. C&lear    Del
  297. clear
  298. Aut&hor    F3
  299. author
  300. &Page
  301. &Next    Alt+Right
  302. &Previous    Alt+Left
  303. previous
  304. &Menu    Alt+Up
  305. first
  306. &Help
  307. &Contents    F1
  308. contents
  309. g: fs2/vo
  310. Linking to MAPI.DLL
  311. Linking to MAPI.DLL
  312. The functions for handling messages in Windows are exported from MAPI.DLL. Click View DLL Functions to see the way these functions are prototyped in OpenScript.ped in OpenScript.
  313. buttonClick
  314. buttonClick
  315. display a 
  316. which 
  317.     -- linking information
  318. &View DLL Functions
  319. Composing Mail
  320. Composing Mail
  321. Composing Mail
  322. Click Compose Message to open the MAPI dialog box you use to compose and send a message.
  323. Click Attach a File if you want to attach a file to the message you compose.....se buttons bring up the MAPI dialog box allowing you to compose and send a message.
  324. The second button attaches a file to the message that you compose.
  325. Compose Message
  326. s_MAPIError
  327. ucomposeMessage
  328. buttonClick
  329. buttonClick
  330. 4s_MAPIError
  331.     -- compose a message
  332. composeMessage()
  333. returned - 
  334. error condition
  335. k <> 
  336. &Compose Message
  337. Attach a File
  338. filename
  339. ZsendFile
  340. s_MAPIerror
  341. buttonClick
  342. buttonClick
  343. 4s_MAPIerror
  344.     -- compose a message 
  345. attached file
  346. sendFile(
  347. "filename")
  348. returned - 
  349. b condition
  350. s_MAPIError <> 
  351. &Attach a File
  352. filename
  353. enterPage
  354. notifyBefore 
  355. C:\JX\MAPI\MAPI.TBKKKKKKKBK
  356. enterPage
  357. Composing Mail
  358. Looking up Addresses
  359. Verifying Names
  360. Counting Messages
  361. Counting Messages
  362. Counting Messages
  363. Click the appropriate button below to count the messages in your incoming mail folder.by stepping through them one at a time.il folder by stepping through them one at a time. This first counts all messages, and the seconds counts only unread messages.
  364. Count All Messages
  365. .&+    +E
  366. .&+    +E
  367. FALSE
  368. str_msgCountAll
  369. l'getNextMsgID
  370. 1RgetFirstMsgID
  371. buttonClick
  372. buttonClick
  373. ZLONG count
  374. the ID 
  375. message (read 
  376. unread)
  377. getFirstMsgID(FALSE)
  378. found
  379.         -- 
  380. getNextMsgID(
  381. str_msgCountAll(
  382. Count &All Messages
  383. Count Unread Messages
  384. .&+    +E
  385. .&+    +E
  386. l'getNextMsgID
  387. Dstr_msgCountUnread
  388. 1RgetFirstMsgID
  389. buttonClick
  390. buttonClick
  391. ZLONG count
  392. the ID 
  393. message (read 
  394. unread)
  395. getFirstMsgID(TRUE)
  396. found
  397.         -- 
  398. getNextMsgID(
  399. str_msgCountUnread(
  400. Count &Unread Messages
  401. Arial
  402. Arial
  403. Arial
  404. Arial
  405.  Sans Serif
  406. Arial
  407. Arial
  408. MS Sans Serif
  409. Page id 23
  410. examples
  411. Page "Submit Reports"
  412. MAPI Tutorial
  413. examples
  414. Submit Reports
  415. department
  416. Salestingnt
  417. Development
  418. Executive
  419. Finance
  420. Marketing
  421. Sales
  422. Technical Support
  423. Testings
  424. problem
  425. Hardware Problemtion
  426. E-Mail
  427. Hardware Installation
  428. Hardware Problem
  429. Network
  430. Other
  431. Phones
  432. Printers
  433. Software Installation
  434. Software Problem
  435. office
  436. phone
  437. x3434
  438. description
  439. My machine won't boot right. The disk keeps running and running but nothing happens.
  440. Change Address
  441. nameList
  442. getAddress
  443. buttonClick
  444. buttonClick
  445.     -- call up the Addressbook dialog 
  446. a list 
  447. names
  448.     nameList = getAddress()
  449. namelist 
  450. &Change Address
  451. Receive Reports
  452. Receive Reports
  453. buttonClick
  454. buttonClick
  455. "Receive Reports"
  456. ceive Reports
  457. examples
  458. buttonClick
  459. buttonClick
  460. the example 
  461. Fclose 
  462. isOpen 
  463. "examples"
  464. &Done
  465. Jim Geldmacher
  466. str_problemRep
  467. enterPage
  468. subject 
  469. standard 
  470. reports
  471. notifybefore 
  472. = str_problemRep()
  473. Problem Report
  474. toLabel
  475. Address:
  476. toLabel
  477. Subject:
  478. toLabel
  479. Department:
  480. toLabel
  481. Problem Area:
  482. toLabel
  483. Phone::::::::
  484. toLabel
  485. Office: Area:
  486. toLabel
  487. Description of problem:
  488. Submit Report
  489. Office:
  490. Department:
  491. phone
  492. description
  493. problem
  494. Problem Report
  495. Phone:
  496. Description:
  497. Problem:
  498. sendMessage
  499. nstr_notSubmit
  500. s_MAPIError
  501. office
  502. department
  503. str_submit
  504. buttonClick
  505. buttonClick
  506. 4s_MAPIError
  507. ZmsgTxt
  508.     -- build the 
  509. message
  510. ' = "Problem Report"
  511. D = "Department:"
  512. combobox "department"
  513. 3problem"
  514.  = "Office:"
  515. "office"
  516.  = "Phone:"
  517. "phone"
  518.  = "Description:"
  519. "description" 
  520. sendMessage(
  521. "sub",
  522. str_notSubmit()&&
  523. str_submit()
  524. bmit Report
  525. enterPage
  526. &Submit Report
  527. &Receive Reports
  528. GvGvG
  529.     -- update the status 
  530. updateMessages
  531. 4LONG s_MsgCount,s_MsgNum
  532.     -- initialize 
  533. flist 
  534. messages
  535. initMessageList str_problemRep()
  536. there 
  537. )least one 
  538. z > 0
  539.         -- 
  540. invalid reset 
  541.  = 0 
  542.         -- parse 
  543. current 
  544. parseMsgText
  545.         -- 
  546. browsing buttons
  547.             enabled 
  548. " = FALSE
  549. " = TRUE
  550. t" = 
  551. t" = 
  552. B"delete" = 
  553.         -- 
  554. are no 
  555.  fields
  556. "msgnum" = str_noMessages()
  557. "address"
  558. "department"
  559. "office"
  560. "phone"
  561. "description"
  562. "timestamp"
  563.         -- 
  564. t" = 
  565. -- generate a 
  566.  than contain 
  567. filter 
  568. their subjects
  569. 4s_MsgHandles
  570. 4s_MAPIerror
  571. ZlastID
  572. ZmsgSub
  573. getFirstMsgID(
  574. more 
  575.         -- 
  576.  = getMsgSub(
  577.         -- 
  578.         -- 
  579. getNextMsgID(
  580. -- take 
  581. fill 
  582. appropriate 
  583. 4s_MAPIError
  584. ZmsgTxt
  585. ender 
  586. getCurrentMsgName()
  587. k&str_update() 
  588. fstr_OK() 
  589. str_cancel()
  590.  = getCurrentMsgText()
  591. &&str_of()&&
  592.  = getCurrentMsgDate()
  593.  returns 
  594. getMsgName(
  595. getMsgText(
  596. getMsgDate(
  597. buttonClick
  598. ZnameText,subText,scrollText
  599. ZLONG msgNum
  600. the ID 
  601. unread message
  602. getFirstMsgID(TRUE)
  603.     -- repeat 
  604. Zno more messages are found
  605.     -- optimization: 
  606. faster 
  607. aincremental 
  608. Fplace 
  609. , than 
  610. Qdirectly 
  611. . In 
  612. list 
  613. generated one 
  614. Fplaced 
  615. fields 
  616. complete.
  617.         -- extract 
  618. sender 
  619.  = getMsgName(
  620.         -- 
  621. subject 
  622.  = getMsgSub(
  623.         -- 
  624. places dummy 
  625. (only 
  626.         -- 
  627. shows on th 
  628.         -- 
  629. technique allows you 
  630.         -- much 
  631. smoothly
  632.         -- 
  633. getNextMsgID(
  634. str_noUnread()
  635.         -- 
  636. "Subject" = 
  637. "ScrollBar" = 
  638.  1993,1994. Asymetrix Corporation. All Rights Reserved.
  639. -- Author: Jim Geldmacher
  640. Mgives you permission 
  641. e, revise, 
  642. reuse the
  643. -- individual 
  644. scripts 
  645. your own
  646. -- applications.
  647. You may 
  648. H entire 
  649. -- substantial part 
  650. redistribution 
  651. ` product.
  652. retains 
  653.  copyright on 
  654.  original elements 
  655.  . Include 
  656.  notice
  657. --     "Portions 
  658.  1993, 1994. 
  659. they contain 
  660. copied 
  661. -- Standard ToolBook messages
  662. enterApplication
  663. xsysRuntime
  664.     -- link 
  665.  DLLs
  666. initLinks
  667. MAPI 
  668. available 
  669. isMAPIAvailable()
  670. SessionLogon()
  671. str_noMAPI()
  672. leaveApplication
  673. 4s_SessionHandle
  674. logged 
  675. ' <> 
  676. SessionLogoff()
  677. unlinkMAPI
  678.     -- unlinkDLLs
  679. related functions
  680. -- Notes:
  681. -- Functions that are exported 
  682. z have 
  683. four 
  684. their 
  685. other 
  686. y used 
  687. Udefined 
  688. %OpenScript "
  689. -- handlers.
  690. -- The basic 
  691. need 
  692. access 
  693. examples 
  694. -- here.
  695. -- There 
  696. two structures 
  697. store recipients
  698. Recipient Structure
  699. -- Offset    Type    Element
  700. --    0        DWORD    
  701.  Must be 0
  702. --    4        
  703. JClass
  704. --    8        POINTER    Pointer 
  705. Name 
  706. --    12        
  707. Address 
  708. --    16        
  709. \Size 
  710. Entry ID 
  711. bytes
  712. --    20        
  713. buffer.
  714. Classes
  715. --    0 = 
  716.  originator
  717. --    1 = primary 
  718. --    2 = ropy 
  719. --    3 = blind 
  720. Message 
  721. --    0        
  722. --    4        
  723. Subject 
  724. --    8        
  725. ?Text 
  726. --    12        
  727. . NULL 
  728. mail.
  729. --    16        
  730. Date. Format 
  731. YYYY/MM/DD HH:MM
  732. --    20        
  733. Thread ID. Ignored 
  734. Hsome systems.
  735. --    24        
  736. Mail Flags
  737. --    28        
  738. Sender's 
  739. --    32        
  740. Number 
  741. --    36        
  742. array 
  743. --    40        
  744. file attachments
  745. --    44        
  746.  descriptors
  747.  returns TRUE 
  748. FALSE otherwise.
  749. IsMAPIAvailable
  750. -- According 
  751. spec, 
  752.  should 
  753. a non-zero "
  754. ;" entry
  755. Y [MAIL] section 
  756. WIN.INI 
  757. determine 
  758. support 
  759. does 
  760. z, just a 
  761. ma_GetWinIniVar("
  762. -- sessionLogOn() attempts 
  763. --    If the 
  764. successful, 
  765. "OK" 
  766. returned. Otherwise, s_MAPIError 
  767. SessionLogOn
  768. ZlphSession, retVal
  769. getWinPointer(4)
  770. MAPILogon(
  771. ,"","",1,0,
  772.         -- extract 
  773.  = PointerDWORD(0,
  774.  = str_OK()
  775.         -- 
  776. what error occured
  777. = getMAPIErrorString(
  778.     -- free 
  779. freeWinPointer (
  780. -- sessionLogOff() 
  781. [off 
  782. current 
  783. -- If 
  784. "OK" 
  785. SessionLogOff
  786. MAPILogoff(
  787. ,0,0)
  788.         -- discard 
  789.         -- 
  790. = GetMAPIErrorString(
  791. -- getting 
  792.      IDs
  793. -- getFirstMsgID() 
  794. appropriate type
  795. newMail 
  796. only considers unread 
  797. -- folder 
  798. considered.
  799.  logical 
  800.     ,s_MAPIerror
  801. ZlpMsgSeedID,lpMsgID
  802.  mailFlag
  803. xisType(
  804. ,s_sessionHandle)
  805. str_lostMAPI()
  806.     -- assign buffers 
  807.  flag
  808.  = 32
  809. MAPIFindNext(
  810. , 0, 0, 
  811.         -- 
  812. there 
  813. value
  814.         msgID = 
  815.  = getMAPIerrorString(
  816.         -- 
  817. -- getNextMsgID() 
  818. _ lastID,
  819.  = 32
  820. , 0, 0, 
  821.         -- 
  822.         -- 
  823. -- reading 
  824. -- getMsgName() reads 
  825. specified 
  826. sender. If 
  827. ZlpPtrMsg,
  828. ZlpSender,lpName
  829. ZmsgName
  830.     -- allocate a 
  831. recieve a 
  832. ("envelope") 
  833.     -- 0x00C0 = MAPI_ENVELOPE_ONLY + MAPI_PEEK
  834. MAPIReadMail(
  835.         -- 
  836.         -- 
  837. 0(28,
  838.         -- 
  839.         -- 
  840. MAPIFreeBuffer(
  841. allocated memory
  842. -- getMsgSub() 
  843. subject 
  844. . If 
  845. ZlpSubject
  846. ZmsgSub
  847.     -- 0
  848.         -- 
  849.         -- 
  850.         -- 
  851.         -- 
  852. -- getMsgDate() 
  853. was received. If 
  854. ZlpDate
  855. ZtmpDate,tmpTime
  856. ZmsgDate
  857.     -- 0
  858.         -- 
  859.         -- 
  860. 0(16,
  861.         -- 
  862.         -- 
  863.         -- reformat 
  864. default 
  865. "y/mm/dd"
  866. "h24:
  867. -- getMsgText() 
  868. . If 
  869. ZlpText
  870. ZmsgTxt
  871.  (ignore 
  872.     -- 0x0180 = 
  873.  + MAPI_SUPPRESS_ATTACH
  874.         msgText = 
  875.         -- 
  876.         -- 
  877.         -- 
  878.         -- 
  879. addresses
  880. -- getAddress() calls up 
  881. dialog box. If no 
  882. -- occurs 
  883. list 
  884. W chosen 
  885. ZlpPtrNum
  886. ZlpPtrRec,lpRec
  887.  recNum
  888.  recOffset
  889. ZrecNames
  890.     -- display 
  891. MAPIAddress(
  892. ,0,"",1,"",0,0,1,0,
  893.         -- retrieve 
  894.             -- 
  895.             -- 
  896. through 
  897.  = (i-1)* 24
  898.             -- frre 
  899. names
  900. -- checkNames() takes a 
  901. partial 
  902. 1. If 
  903. > could be
  904. -- resolved 
  905. full mailing 
  906.  consists 
  907. containing 
  908. those 
  909. ZSTACK goodNames,badNames
  910. Xeach 
  911.         -- 
  912.         -- 0x0409 = MAPI_LOGON_UI + MAPI_DIALOG + MAPI_AB_NOMODIFY
  913. MAPIResolveName(
  914.             -- 
  915. pcannot be 
  916.             -- 
  917.             -- 
  918.             lpRecip = 
  919.             -- 
  920.             -- 
  921. valid 
  922.             -- 
  923. -- sending 
  924. -- composeMessage() displays 
  925. coposing
  926. . If 
  927. "OK" 
  928. 4s_Sessionhandle,
  929. blank 
  930.     -- 0x0009 = 
  931. MAPISendMail(0,0,
  932. -- sendFile() opens 
  933.  mesage 
  934. -- attached 
  935. !. Null 
  936. -- "OK" 
  937. l fileName
  938. MAPISendDocuments(0, ";", 
  939. p, shortFileName(
  940. ), 0)
  941. -- sendMessage() sends a 
  942. "OK" 
  943. a recipent 
  944. -- ambiguous 
  945. user will be prompted 
  946. clarify
  947.  recips,
  948. ZlpBuff,lpTmp
  949. Zstack recipStack
  950.   numRec
  951. ZLONG count
  952.     -- find out many 
  953. z"so enough 
  954.     -- can be 
  955.         -- a 
  956.   which 
  957.         -- a 
  958.         -- a 
  959.         -- a 
  960.         -- a 
  961.     -- create a temporary 
  962.     -- fill 
  963.         -- 
  964.         -- 
  965.         -- 0
  966. UI + 
  967.             -- 
  968.             -- 
  969.             -- 
  970. contents 
  971.             -- optimization: 
  972. Windows 
  973. much faster
  974.             -- than stepping 
  975. ma_hmemcpy(
  976.             -- 
  977. 7 counter 
  978.             -- keep track 
  979. cleanup later
  980.  were 
  981.         -- 
  982. strings
  983.         -- 
  984. ,(32,
  985. 0(36,
  986.         -- 
  987. ,1,0)
  988. 5! = 
  989.         -- 
  990.         -- pointers 
  991. :'stored 
  992. %a 2-
  993. order 
  994.         -- 
  995. necessary 
  996. grab 
  997. -- deleting 
  998. -- deleteMessage() removes 
  999. $ "OK 
  1000. MAPIDEleteMail(
  1001. ,0,0)
  1002. e# = 
  1003. t# = 
  1004. -- Utility 
  1005. "code associated 
  1006. # nErrorNumber
  1007.         When 
  1008. "Operation Succeded"            --SUCCESS_SUCCESS 
  1009. "User Aborted"
  1010. --MAPI_USER_ABORT 
  1011. kFailed"            --MAPI_E_FAILURE
  1012. "Login 
  1013. 0    --MAPI_E_LOGIN_FAILURE 
  1014. "Disk Full"
  1015. --MAPI_E_DISK_FULL 
  1016. "Insufficient Memory"        --MAPI_E_INSUFFICIENT_MEMORY 
  1017. "Block Too Small"            --MAPI_E_BLK_TOO_SMALL 
  1018. 5Many Sessions"            --MAPI_E_TOO_MANY_SESSIONS 
  1019. ?Files"
  1020. --MAPI_E_TOO_MANY_FILES 
  1021. yRecipients"        --MAPI_E_TOO_MANY_RECIPIENTS 
  1022. "Attacment Not Found"        --MAPI_E_ATTACHMENT_NOT_FOUND 
  1023. "Failure Opening Attachment"    --
  1024. LOPEN_FAILURE 
  1025. ?Writing 
  1026. |WRITE_FAILURE 
  1027. "Unknown 
  1028. +"            --MAPI_E_UNKNOWN_RECIPIENT 
  1029. "Bad 
  1030. +"            --MAPI_E_BAD_RECIPTYPE 
  1031. "No Messages"
  1032. --MAPI_E_NO_MESSAGES 
  1033. "Invalid 
  1034. ;"            --MAPI_E_INVALID_MESSAGE 
  1035. Large"            --MAPI_E_TEXT_TOO_LARGE 
  1036. /"            --MAPI_E_INVALID_SESSION 
  1037. Supported"            --MAPI_E_TYPE_NOT_SUPPORTED 
  1038. "Ambiguous 
  1039. T-"        --MAPI_E_AMBIGUOUS_RECIPIENT 
  1040. $(:"&& 
  1041. *a filename 
  1042. .has been stripped 
  1043. path information
  1044.  fName
  1045. harCnt, i
  1046.     charCnt = 
  1047. - 1) 
  1048. Vi+1 
  1049. )) allocates a block 
  1050. global 
  1051. ) nSize
  1052. ZhMem,ptr
  1053.  ma_globalAlloc(66,
  1054. %) -- 66 
  1055. Movable, Zero-Init
  1056. str_noMem()
  1057. ma_globalLock(
  1058. v)() frees 
  1059. )lpPointer
  1060.  = ma_globalHandle(
  1061. ') -- 
  1062. Hselector)
  1063. ma_globalUnlock(
  1064. ma_globalFree(
  1065. p1() establishes a 
  1066. H2DLL 
  1067. --    a 
  1068. & indicating 
  1069. found.
  1070.     sysS = 
  1071. provide messaging 
  1072. X"mapi.dll"
  1073. `0, STRING, 
  1074. o1, \
  1075. 1 MAPIDeleteMail (
  1076. .links 
  1077. kernel 
  1078. # managment 
  1079.         INT     
  1080. tbkwin 
  1081. 4 "tb30win.
  1082.     ma_getWinIniVar=
  1083. 4 disconnects 
  1084. str_noUnread
  1085. str_msgCountAll 
  1086. %5"&&
  1087. str_msgCountUnread 
  1088. Z5"&&
  1089. I."&&\
  1090. 5Microsoft 
  1091. 7-compatible e-
  1092. !3 client software installed"&&\
  1093. :6 correctly."        
  1094. I."&&\
  1095. F,"&&\
  1096. -9wish 
  1097. str_notResolved
  1098. "These 
  1099. str_sent
  1100. str_notSent
  1101. str_notSubmit
  1102. "Report 
  1103. xsubmitted:"
  1104. str_submit
  1105. str_notDelete
  1106. xdeleted:"
  1107. str_noMessages
  1108. str_error
  1109. str_update
  1110. "Update 
  1111. str_cancel
  1112. "Cancel"
  1113. str_message
  1114. str_of
  1115. str_problemRep
  1116. "Problem 
  1117. "Aborting operation: 
  1118.  Allocation 
  1119. uupdateMessages
  1120. enterPage
  1121. +%,!"
  1122. +%,!>
  1123. +%,!"
  1124. .&+%?
  1125. problem
  1126. s_MsgNum
  1127. phone
  1128. address
  1129. description
  1130. str_noMessages
  1131. previous
  1132. delete
  1133. 8parseMsgText
  1134. initMessageList
  1135. msgnum
  1136. office
  1137. department
  1138. timestamp
  1139. str_problemRep
  1140. s_MsgCount
  1141. updateMessages
  1142. .&+    +E
  1143. .&+%?
  1144. +%,!Y
  1145. +%,H3
  1146. .&+    +E
  1147. FALSE
  1148. l'getNextMsgID
  1149. getMsgSub
  1150. s_MsgHandles
  1151. 1RgetFirstMsgID
  1152. s_MsgCount
  1153. initMessageList
  1154. w,    #>
  1155. +%,    #?
  1156. w,    #?
  1157. +%,    #?
  1158. address
  1159. s_MAPIError
  1160. phone
  1161. str_cancel
  1162. description
  1163. 'getCurrentMsgText
  1164. str_message
  1165. getCurrentMsgDate
  1166. problem
  1167. uupdateMessages
  1168. str_OK
  1169. getCurrentMsgName
  1170. msgnum
  1171. str_update
  1172. str_of
  1173. s_MsgNum
  1174. Error:
  1175. office
  1176. department
  1177. timestamp
  1178. s_MsgCount
  1179. parseMsgText
  1180. +%,H3
  1181. s_MsgNum
  1182. s_MsgHandles
  1183. getMsgName
  1184. getCurrentMsgName
  1185. +%,H3
  1186. getMsgText
  1187. s_MsgNum
  1188. s_MsgHandles
  1189. getCurrentMsgText
  1190. +%,H3
  1191. s_MsgNum
  1192. s_MsgHandles
  1193. getMsgDate
  1194. getCurrentMsgDate
  1195. .&+    +E
  1196. .%,    7
  1197. .&+    +E
  1198. (str_noUnread
  1199. l'getNextMsgID
  1200. ScrollBar
  1201. getMsgSub
  1202. 1RgetFirstMsgID
  1203. Subject
  1204. getMsgName
  1205. buttonClick
  1206. initLinks
  1207. 3SessionLogon
  1208. isMAPIAvailable
  1209. str_noMAPI
  1210. enterApplication
  1211. unlinkDLLs
  1212. s_SessionHandle
  1213. USessionLogoff
  1214. unlinkMAPI
  1215. leaveApplication
  1216. reader
  1217. FALSE
  1218. ma_GetWinIniVar
  1219. clinkMAPI
  1220. IsMAPIAvailable
  1221. freeWinPointer
  1222. $bgetWinPointer
  1223. MAPILogon
  1224. s_SessionHandle
  1225. str_OK
  1226. DgetMAPIErrorString
  1227. s_MAPIError
  1228. SessionLogOn
  1229. s_SessionHandle
  1230. str_OK
  1231. MAPILogoff
  1232. DGetMAPIErrorString
  1233. s_MAPIError
  1234. SessionLogOff
  1235. .&+    +E
  1236. $bgetWinPointer
  1237. msgID
  1238. s_SessionHandle
  1239. MAPIFindNext
  1240. d3str_lostMAPI
  1241. DgetMAPIerrorString
  1242. s_MAPIerror
  1243. getFirstMsgID
  1244. .&+    +E
  1245. $bgetWinPointer
  1246. s_SessionHandle
  1247. lpMsgSeedID
  1248. MAPIFindNext
  1249. d3str_lostMAPI
  1250. DgetMAPIerrorString
  1251. s_MAPIerror
  1252. lpMsgID
  1253. getNextMsgID
  1254. .&+    +E
  1255. freeWinPointer
  1256. $bgetWinPointer
  1257. s_SessionHandle
  1258. 8aMAPIFreeBuffer
  1259. d3str_lostMAPI
  1260. DgetMAPIErrorString
  1261. s_MAPIerror
  1262. MAPIReadMail
  1263. getMsgName
  1264. .&+    +E
  1265. freeWinPointer
  1266. $bgetWinPointer
  1267. s_SessionHandle
  1268. 8aMAPIFreeBuffer
  1269. d3str_lostMAPI
  1270. DgetMAPIErrorString
  1271. s_MAPIerror
  1272. MAPIReadMail
  1273. getMsgSub
  1274. .&+    +E
  1275. freeWinPointer
  1276. $bgetWinPointer
  1277. s_SessionHandle
  1278. 8aMAPIFreeBuffer
  1279. y/mm/dd
  1280. d3str_lostMAPI
  1281. DgetMAPIErrorString
  1282. s_MAPIerror
  1283. h24:min
  1284. MAPIReadMail
  1285. getMsgDate
  1286. .&+    +E
  1287. freeWinPointer
  1288. $bgetWinPointer
  1289. s_SessionHandle
  1290. 8aMAPIFreeBuffer
  1291. d3str_lostMAPI
  1292. DgetMAPIErrorString
  1293. s_MAPIerror
  1294. msgText
  1295. MAPIReadMail
  1296. getMsgText
  1297. .&+    +E
  1298. ,%H.%
  1299. freeWinPointer
  1300. $bgetWinPointer
  1301. s_SessionHandle
  1302. 8aMAPIFreeBuffer
  1303. MAPIAddress
  1304. d3str_lostMAPI
  1305. DgetMAPIErrorString
  1306. s_MAPIError
  1307. getAddress
  1308. .&+    +E
  1309. ,%H.%
  1310. freeWinPointer
  1311. $bgetWinPointer
  1312. s_SessionHandle
  1313. 8aMAPIFreeBuffer
  1314. MAPIResolveName
  1315. d3str_lostMAPI
  1316. DgetMAPIerrorString
  1317. s_MAPIError
  1318. checkNames
  1319. .&+    +E
  1320. freeWinPointer
  1321. $bgetWinPointer
  1322. s_Sessionhandle
  1323. str_OK
  1324. d3str_lostMAPI
  1325. DgetMAPIErrorString
  1326. s_MAPIError
  1327. MAPISendMail
  1328. composeMessage
  1329. .&+    +E
  1330. s_Sessionhandle
  1331. MAPISendDocuments
  1332. str_OK
  1333. HshortFileName
  1334. d3str_lostMAPI
  1335. DgetMAPIErrorString
  1336. s_MAPIError
  1337. sendFile
  1338. .&+    +E
  1339. freeWinPointer
  1340. $bgetWinPointer
  1341. ma_hmemcpy
  1342. s_Sessionhandle
  1343. str_OK
  1344. 8aMAPIFreeBuffer
  1345. MAPISendMail
  1346. MAPIResolveName
  1347. d3str_lostMAPI
  1348. DgetMAPIerrorString
  1349. s_MAPIError
  1350. recipient
  1351. sendMessage
  1352. .&+    +E
  1353. [MAPIDEleteMail
  1354. s_SessionHandle
  1355. str_OK
  1356. d3str_lostMAPI
  1357. DgetMAPIerrorString
  1358. s_MAPIError
  1359. deleteMessage
  1360. .&,    "
  1361. .&,    "
  1362. .&,    "
  1363. .&,    "
  1364. .&,    "
  1365. .&,    "
  1366. .&,    "
  1367. .&,    "
  1368. .&,    "
  1369. .&,    "
  1370. .&,    "
  1371. .&,    "
  1372. .&,    "
  1373. .&,    "
  1374. .&,    "
  1375. .&,    "
  1376. .&,    "
  1377. .&,    "
  1378. .&,    "
  1379. .&,    "
  1380. .&,    "
  1381. Too Many Sessions
  1382. Too Many Files
  1383. Invalid Message
  1384. Block Too Small
  1385. Too Many Recipients
  1386. Failure Opening Attachment
  1387. Invalid Session
  1388. Attacment Not Found
  1389. Failure Writing Attachment
  1390. Bad Recipient Type
  1391. Type Not Supported
  1392. Insufficient Memory
  1393. No Messages
  1394. Disk Full
  1395. Login Failed
  1396. Operation Succeded
  1397. Text is Too Large
  1398. Unknown Recipient
  1399. User Aborted
  1400. Operation Failed
  1401. Unknown error:
  1402. Ambiguous Recipient
  1403. getMAPIErrorString
  1404. shortFileName
  1405. &ma_globalLock
  1406. str_noMem
  1407. Kma_globalAlloc
  1408. getWinPointer
  1409. !pma_globalHandle
  1410. ma_globalUnlock
  1411. } ma_globalFree
  1412. freeWinPointer
  1413. MAPILogoff
  1414. ,&UgF
  1415. MAPILogon
  1416. MAPIFindNext
  1417. MAPIFreeBuffer
  1418. MAPISendMail
  1419. MAPIReadMail
  1420. ,BUny F.&
  1421. MAPIResolveName
  1422. MAPISendDocuments
  1423. MAPIAddress
  1424. MAPIDeleteMail
  1425. mapi.dll
  1426. linkMAPI
  1427. tb30win.dll
  1428. globalAlloc
  1429. ma_globalAlloc
  1430. globalLock
  1431. ma_globalLock
  1432. ,#UF    
  1433. globalUnlock
  1434. ma_globalUnlock
  1435. ,#TOHIf-"
  1436. globalFree
  1437. ma_globalFree
  1438. globalHandle
  1439. ma_globalHandle
  1440. ,"TgF    
  1441. hmemcpy
  1442. ma_hmemcpy
  1443. getWinIniVar
  1444. ma_getWinIniVar
  1445. kernel
  1446. initLinks
  1447. mapi.dll
  1448. unlinkMAPI
  1449. tb30win.dll
  1450. kernel
  1451. unlinkDLLs
  1452. You have no unread messages.
  1453. str_noUnread
  1454. You have
  1455. messages.
  1456. str_msgCountAll
  1457. unread messages.
  1458. You have
  1459. str_msgCountUnread
  1460. MAPI is not available at this time.
  1461. You need to have Microsoft Mail or MAPI-compatible e-mail client software installed
  1462. for the examples in this book to function correctly.
  1463. str_noMAPI
  1464. The examples in this book will not function correctly,
  1465. MAPI is not available at this time.
  1466. you may wish to exit.
  1467. str_lostMAPI
  1468. str_OK
  1469. These names could not be resolved:
  1470. str_notResolved
  1471. Message sent.
  1472. str_sent
  1473. Message not sent:
  1474. str_notSent
  1475. Report not submitted:
  1476. str_notSubmit
  1477. Report submitted.
  1478. str_submit
  1479. Message not deleted:
  1480. str_notDelete
  1481. No messages
  1482. str_noMessages
  1483. Error:
  1484. str_error
  1485. Update Messages?
  1486. str_update
  1487. Cancel
  1488. str_cancel
  1489. Message
  1490. str_message
  1491. str_of
  1492. Problem Report
  1493. str_problemRep
  1494. Aborting operation: Memory Allocation Error.
  1495. str_noMem
  1496. xdeleted:"
  1497. str_noM
  1498. examples
  1499. in,true
  1500. ThreeDeeRect
  1501. text area
  1502. bottomLine
  1503. topLine
  1504. description
  1505. description
  1506. enterpage
  1507. doesn't fit, 
  1508. notifybefore 
  1509. "description" 
  1510. Front
  1511. front
  1512. enterpage
  1513. handler keeps the title 
  1514. synchronized
  1515. notifybefore 
  1516. "front" 
  1517. Previous
  1518. buttonClick
  1519. enterPage
  1520. .one 
  1521. buttonClick
  1522. -- determine 
  1523. navigation 
  1524. should be allowed
  1525. notifybefore 
  1526. on a different 
  1527. oenabled = (
  1528. main menu
  1529. buttonClick
  1530. main menu
  1531. enterPage
  1532. the main 
  1533. buttonClick
  1534. -- determine 
  1535. Bnavigation 
  1536. Ienu 
  1537. should be allowed:
  1538. notifybefore 
  1539. ycurrent 
  1540. oenabled = (
  1541. buttonClick
  1542. enterPage
  1543. buttonClick
  1544. -- determine 
  1545. navigation 
  1546. should be allowed
  1547. notifybefore 
  1548. on a different 
  1549. oenabled = (
  1550. in,true
  1551. ThreeDeeRect
  1552. work area
  1553. bottomLine
  1554. topLine
  1555. enterPage
  1556. main menu
  1557. -- a notify handler was used 
  1558. update 
  1559. you enter 
  1560. Main Menu
  1561. Main Menu
  1562. buttonClick
  1563. ,%H.%
  1564. front
  1565. enterpage
  1566. buttonClick
  1567. ZLONG lineNum
  1568.     -- determine which 
  1569. Uwas selected 
  1570. * = selectedTextlines 
  1571. that 
  1572. -- update the 
  1573. list 
  1574. notifybefore 
  1575. ZSTRING newText
  1576.     -- generate a 
  1577.     -- optimization: 
  1578. faster 
  1579. aincremental 
  1580. place 
  1581. , than 
  1582.     -- directly 
  1583. B(i-1) 
  1584. J"front" 
  1585. Using MAPI
  1586. Linking to MAPI.DLL
  1587. Looking up Addresses
  1588. Verifying Names
  1589. Checking For Unread Mail
  1590. Counting Messages
  1591. Composing Mail
  1592. Sending Messages
  1593. Example: Problem Reports
  1594. Choose one of these topics:low by clicking on its name:
  1595. enterpage
  1596. Example: Problem Reports
  1597. Example: Problem Reports
  1598. Example: Problem Reports+
  1599. The following two examples demonstrate how a small MAPI application, such as a custom e-mail form, might be built in ToolBook. 
  1600. The first example is a guided input form for submitting problem reports. The user simply fills in the blanks and clicks on a button to submit the report.
  1601. The second example scans the user's incoming mail folder for problem reports submitted using the e-mail form. This provides a simple interface for browsing through these messages...................................
  1602. Submit Reports
  1603. examples
  1604. Submit Reports
  1605. buttonClick
  1606. buttonClick
  1607.     -- display a 
  1608. example
  1609. "examples"
  1610.     currentpage 
  1611. "Submit Reports"
  1612. &Submit Reports
  1613. Receive Reports
  1614. Receive Reports
  1615. examples
  1616. buttonClick
  1617. buttonClick
  1618.     -- display a 
  1619. example
  1620. "examples"
  1621.     currentpage 
  1622. "Receive Reports"
  1623. &Receive Reports
  1624. main menu
  1625. right
  1626. grey all
  1627. grey left
  1628. grey right
  1629. Looking up Addresses
  1630. -- a notify handler was used 
  1631. the address 
  1632. you enter 
  1633. Looking up Addressesok]
  1634. Looking up Addressesokkess Book
  1635. Click Look Up Address to display the dialog box MAPI provides for choosing addresses. Names you select from the list will be placed in the field below...........................
  1636. Look Up Address
  1637. nameList
  1638. getAddress
  1639. s_MAPIError
  1640. buttonClick
  1641. buttonClick
  1642. 4s_MAPIError
  1643. up the Address Book dialog 
  1644. retrieve a list 
  1645. names
  1646.     nameList = getAddress()
  1647. returned - 
  1648. error condition
  1649. &Look Up Address
  1650. enterPage
  1651. notifybefore 
  1652. enterPage
  1653.